<template>
  <section>
    <!--工具条-->
    <el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
      <el-form :inline="true" :model="filters">
        <el-form-item>
          <el-input v-model="filters.name" placeholder="订单名称"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" v-on:click="selectAdoptOrders">查询</el-button>
        </el-form-item>
      </el-form>
    </el-col>

    <!--列表-->
    <el-table :data="AdoptOrders" highlight-current-row v-loading="listLoading"
              @selection-change="selsChange" style="width: 100%;">
      <el-table-column type="selection" width="55">
      </el-table-column>
      <el-table-column type="index" label="序号" width="60">
      </el-table-column>
      <el-table-column prop="orderSn" label="订单号" width="150">
      </el-table-column>
      <el-table-column prop="state" label="状态" width="80" sortable>
        <template scope="scope">
          <span v-if="scope.row.state==-1" style="color: hotpink">取消</span>
          <span v-if="scope.row.state==0" style="color: blue">待支付</span>
          <span v-if="scope.row.state==1" style="color: green">待确认</span>
          <span v-if="scope.row.state==2" style="color: red">完成</span>
        </template>
      </el-table-column>
      <el-table-column prop="petName" label="宠物名" width="250" e>
      </el-table-column>
      <el-table-column prop="username" label="用户" width="150">
      </el-table-column>
      <el-table-column prop="phone" label="联系方式" width="150">
      </el-table-column>
      <el-table-column prop="shopName" label="店铺" width="150">
      </el-table-column>
      <el-table-column prop="address" label="地址" >
      </el-table-column>
      <el-table-column label="操作" width="250">
        <template scope="scope">
          <el-button size="small" type="info" disabled @click="handleEdit(scope.$index, scope.row)">确认配送</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--工具条-->
    <el-col :span="24" class="toolbar">
      <el-pagination layout="prev, pager, next"
                     @current-change="handleCurrentChange"
                     :page-size="pageSize"
                     :total="totals"
                     :current-page="currentPage"
                     style="float:right;">
      </el-pagination>
    </el-col>
  </section>
</template>

<script>

export default {
  data() {
    return {
      filters: {
        name: ''
      },
      emps: [],
      AdoptOrders: [],
      options: [],
      totals: 0,
      currentPage: 1,
      pageSize: 5,
      title: '',
      listLoading: false,
      sels: [],//列表选中列
    }
  },
  methods: {
    handlePreview(file) {
      console.log(file);
    },
    selectAdoptOrders() {
      this.currentPage = 1;
      this.getAdoptOrders();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getAdoptOrders();
    },
    //获取订单列表
    getAdoptOrders() {
      let para = {
        currentPage: this.currentPage,
        pageSize: this.pageSize,
        keyword: this.filters.name
      };
      this.listLoading = true;
      this.$http.post("/orderAdopt/pageList", para).then((res) => {
          this.AdoptOrders = res.data.data;
          this.totals = res.data.totals;
          this.listLoading = false;
      }).catch((res => {
        this.$message.error("网络繁忙");
      }));
    },
    selsChange: function (sels) {
      this.sels = sels;
    },
  },
  mounted() {
    this.getAdoptOrders();
  }
}

</script>

<style scoped>

</style>